package com.ecc.base;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**   
 * @Description:TODO
 * @author: lxh 
 * @date: 2018年6月11日
 */
//@Controller
public class MainsiteErrorController implements ErrorController{
	 private static final String ERROR_PATH = "/error";  
	 
	 
	 @RequestMapping(value=ERROR_PATH)  
	 public String handleError(HttpServletRequest request, HttpServletResponse response){  
		Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
		System.out.println("error_code:"+statusCode);
        if(statusCode == 401){
            return "error/401";
        }else if(statusCode == 404){
            return "error/404";
        }else if(statusCode == 403){
            return "error/403";
        }else{
            return "error/500";
        }
	 }  
	 
	 
	 @Override  
	 public String getErrorPath() {  
	    return ERROR_PATH;  
	 }  
}
